import akshare as ak
import pandas as pd
import rule


#获取数据


#获取实时-试试
def get_data_realtime():
    stock_zh_a_hist_df = ak.stock_zh_a_minute('sh600000','5')#A股分时历史行情
    data_test = stock_zh_a_hist_df.iloc[-100:-1]
    #清空EXCEL
    file_path = 'd:/test/t2.xlsx'
    pd.DataFrame().to_excel(file_path)
    #写入EXCEL
    data_test.to_excel('d:/test/t2.xlsx')
    return data_test
#从EXCEL读取数据
def get_data_excel():
    file_path = 'd:/test/t2.xlsx'
    data_test = pd.read_excel(file_path,index_col=0)
    return data_test

#平线中枢范围，1=最大范围，2=公共范围
line3_type = 2


# #计算K线
# result = rule.judge_k_list(get_data_realtime(),line3_type)
result = rule.judge_k_list(get_data_excel(),line3_type)
#将数据写入EXCEL
# data_test.to_excel('d:/test/t2.xlsx')